package com.example.activity.vo;

import com.github.pagehelper.PageInfo;
import lombok.Data;

import java.util.List;

/**
 * 分页返回对象
 * @param <T>
 */
@Data
public class PageResultVO<T> {
    /**
     * 分页页码
     */
    private Integer pageNum;

    /**
     * 分页大小
     */
    private Integer pageSize;

    /**
     * 总数
     */
    private Integer total;

    private List<T> dataList;

    public PageResultVO() {
    }

    public PageResultVO(Integer pageNum, Integer pageSize, Integer total, List<T> dataList) {
        this.pageNum = pageNum;
        this.pageSize = pageSize;
        this.total = total;
        this.dataList = dataList;
    }

    public PageResultVO(PageInfo<T> pageInfo, List<T> dataList) {
        this.pageNum = pageInfo.getPageNum();
        this.pageSize = pageInfo.getPageSize();
        this.total = Math.toIntExact(pageInfo.getTotal());
        this.dataList = dataList;
    }

}
